<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xhtml="http://www.w3.org/1999/xhtml" xmlns="http://www.w3.org/1999/xhtml" 
	xmlns:xsl="http://www.w3.org/1999/XSL/Transform" exclude-result-prefixes="xhtml xsl">
	<xsl:output method="html" media-type="text/xhtml" omit-xml-declaration="yes" 
	version="1.0" encoding="UTF-8" doctype-public="-//W3C//DTD XHTML 1.0 Strict//EN" 
	doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd" indent="yes"/>
	
	<xsl:include href="headData.xsl" />

	<xsl:template match="normalBox/field">
		<div class="labelText">
		<label for="{id}">
		<xsl:value-of select="nameField" />
		<xsl:if test="nameField/@obbligatory='1'">
		*
		</xsl:if>
		</label> 
		<input id="{id}" name="{id}">
			<xsl:if test="size != 0">
				 <xsl:attribute name="size">
					<xsl:value-of select="size" />
				 </xsl:attribute>
			</xsl:if>
			<xsl:choose>
				<xsl:when test="type">
					 <xsl:attribute name="type">
						<xsl:value-of select="type" />
					 </xsl:attribute>
				</xsl:when>
				<xsl:otherwise>
				 <xsl:attribute name="type">text</xsl:attribute>
				</xsl:otherwise>
			</xsl:choose>
			 <xsl:if test="nameField/@obbligatory='1'">
				 <xsl:attribute name="onblur">testEmpty('<xsl:value-of select="id" />','<xsl:value-of select="../warning" />');</xsl:attribute>
				 <xsl:attribute name="onfocus">cleanWarning('<xsl:value-of select="id" />');</xsl:attribute>
			 </xsl:if>
		</input>

		</div>
	</xsl:template>
		
	<xsl:template match="form">
		<xsl:if test="./warnBox">
			<span class="__warnBoxClass__">__warnBoxContent__</span>
		</xsl:if>
		<xsl:if test="obligatory">
			* <xsl:value-of select="obligatory" />
		</xsl:if>
		<form action="{//content/form/@action}" method="{//content/form/@method}" enctype="{//content/form/@enctype}">
		<xsl:for-each select="normalBox">
			<fieldset>
				<legend>
				<xsl:value-of select="./desc" />
				</legend>
				<xsl:for-each select="./*">
					<xsl:if test="name() = 'field'">
						<xsl:apply-templates select="."/>
					</xsl:if>

					<xsl:if test="name() = 'imgBookFile'">
						<span><label for="book_cover">
						<xsl:value-of select="." />
						</label> <input type="file" id="book_cover" name="book_cover" size="50" /></span> 
					</xsl:if>
					<xsl:if test="name() = 'textarea'">
						<label for="book_description">
						<xsl:value-of select="." />
						</label> 
						<textarea id="book_description" name="book_description" cols="80" rows="2"></textarea>
					</xsl:if>
					<xsl:if test="name() = 'checkbox'">
						<div class="labelCheck"><label for="{@name}"><xsl:value-of select="." /></label>
						<input name="{@name}" id="{@name}" type="checkbox" value="{@value}">
							<xsl:if test="@checked">
								 <xsl:attribute name="checked">
									<xsl:value-of select="@checked" />
								 </xsl:attribute>
							</xsl:if>
						</input>
						</div>
					</xsl:if>
					<xsl:if test="name() = 'freeText'">
						<p>
							<xsl:copy-of select="." />
						</p>
					</xsl:if>
					<xsl:if test="name() = 'submit'">
						 <input type="submit" value="{.}" />
					</xsl:if>
					<xsl:if test="name() = 'reset'">
						 <input type="reset" value="{.}" />
					</xsl:if>
				</xsl:for-each>
				<xsl:if test="./hidden">
					<xsl:comment>§§start</xsl:comment>
						<input type="hidden" id="__idHiddenINDEX__" name="__idHiddenINDEX__" value="__valueHiddenINDEX__" />
					<xsl:comment>§§end</xsl:comment>
				</xsl:if>
			</fieldset>
		</xsl:for-each>
			<xsl:if test="secondBox">
				<xsl:apply-templates select="secondBox"/>
			</xsl:if>
			<xsl:if test="thirdBox">
				<xsl:apply-templates select="thirdBox"/>
			</xsl:if>
	</form>
	</xsl:template>
	
	<xsl:template match="content">
			<div id="content">
			<xsl:apply-templates select="titleContent"/>
			<xsl:apply-templates select="form"/>
			<span id="endContent"></span>
			</div>
	</xsl:template>
	
</xsl:stylesheet>
